package Math;
public class APIMathdemo04 {
    //153=1^3+5^3+3^3
    //一个n位数等于
    public static void main(String[] args) {
        int count = 0;
        for (int i = 100; i <= 9999; i++) {
            boolean result = fun(i);
            if (result) {
                count++;
                System.out.println(i);
            } else {
                continue;
            }
        }
        System.out.println(count + "个水仙花数");

    }

    private static boolean fun(int num) {
        int ret = num;
        int sum = 0;
        while (ret != 0) {
            sum += Math.pow(ret % 10, 3);
            ret /= 10;
        }
        if (sum == num) {
            return true;
        } else {
            return false;
        }

    }
}
